-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: should revert tx when block gas limit exceeded #10770
Conversation
good to back port to 0.45 @robert-zaremba @aaronc @alexanderbez |
Also, let's add a few tests for this. Thanks @ethanfrey 🙏 |
3760624
to
93ac439
Compare
93ac439
to
0f263de
Compare
I've redone the PR in a cleaner way, by creating a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this SnapshotMiddleware solution
a834885
to
4c54a5e
Compare
I'm not sure how to write a unit test for this though, it seems we need to execute some msg that does storage operations, then we can check the side-effects are reverted when the block gas limit is exceeded. |
Do you think there's a similar issue with this tip logic: https://github.com/cosmos/cosmos-sdk/blob/master/x/auth/middleware/tips.go#L38 . It's also executed after tx msgs, and it seems to be possible to return error. Maybe we should put it inside the |
|
Yes you're right. But with the current code, the TipsMiddleware is already inside SnapshotTxMiddleware (see #10770 (comment)), so all good |
38ff9aa
to
b3bb21d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, just a small nit: given it's now renamed PersistTxMiddleware
, perhaps the file could be persist_tx.go
or persist.go
instead of snapshot.go
for consistency?
yeah, good catch, done. |
Here is the followup issue: #10908 . It requires bigger refactor, so we won't be able to handle it in this PR unfortunately. In this PR: let's add the missing tests and see what we can fix in the middleware we are changing. |
I'm looking forward to 0.45 release and this seems like the only blocker left. Are there concrete actions needed for this? "Missing tests and fix the middleware" are a bit vague. |
Closes: cosmos#10769 Solution: - create a `WithBranchedStore` to handle state snapshot and revert - extract `ConsumeBlockGasMiddleware` out from `RecoveryTxMiddleware`. - order the middlewares properly. Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com> Apply suggestions from code review Co-authored-by: Robert Zaremba <robert@zaremba.ch>
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
1a47b58
to
af0cc18
Compare
@robert-zaremba are you okay to lift the block, and implementing more complex gas deductions/refunds in a later PR? |
I agree this is a nice addition but outside the scope of the PR. We'd be happy to collaborate on a design |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding tests. I've already created a new issue for other updates discussing here.
Nice, adding automerge! I removed the backport label, there's already #10814 |
- used a different solution. changelog
* revert tx when block gas limit exceeded (backport: #10770) - used a different solution. changelog * add unit test * Update baseapp/baseapp.go Co-authored-by: Robert Zaremba <robert@zaremba.ch> * simplfy the defer function Co-authored-by: Robert Zaremba <robert@zaremba.ch>
…cosmos#10814) * revert tx when block gas limit exceeded (backport: cosmos#10770) - used a different solution. changelog * add unit test * Update baseapp/baseapp.go Co-authored-by: Robert Zaremba <robert@zaremba.ch> * simplfy the defer function Co-authored-by: Robert Zaremba <robert@zaremba.ch>
…cosmos#10814) * revert tx when block gas limit exceeded (backport: cosmos#10770) - used a different solution. changelog * add unit test * Update baseapp/baseapp.go Co-authored-by: Robert Zaremba <robert@zaremba.ch> * simplfy the defer function Co-authored-by: Robert Zaremba <robert@zaremba.ch>
…cosmos#10814) * revert tx when block gas limit exceeded (backport: cosmos#10770) - used a different solution. changelog * add unit test * Update baseapp/baseapp.go Co-authored-by: Robert Zaremba <robert@zaremba.ch> * simplfy the defer function Co-authored-by: Robert Zaremba <robert@zaremba.ch>
Closes: #10769
Description
Solution:
WithBranchedStore
to handle state snapshot and revertConsumeBlockGasMiddleware
out fromRecoveryTxMiddleware
.Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change